#!/usr/bin/env python3
import os
import math
import pygame
from pygame.locals import *

#do a bunch of behind the scenes setup to make pygame usable
pygame.init()

###########################
# Set up the game window  #
###########################
        
#screen dimension variables     
screenh = 400
screenw = 400

#http://www.pygame.org/docs/ref/display.html#pygame.display.set_mode
#screen is a pygame.Surface object
#this is the game window
screen = pygame.display.set_mode((screenh, screenw))

#http://www.pygame.org/docs/ref/display.html#pygame.display.set_caption
pygame.display.set_caption("Example 1")

#http://www.pygame.org/docs/ref/surface.html
#background is a pygame.Surface object
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((0,0,0))

#http://www.pygame.org/docs/ref/surface.html#pygame.Surface.blit
#draw the background onto the screen
screen.blit(background, (0,0))

# End of game window setup

############################
# Add some objects to the  #
# screen using pygame.draw #
############################
# http://www.pygame.org/docs/ref/draw.html
pygame.draw.rect(screen,         # Where to draw the rect
                 (255,0,0),      # the color (r,g,b)
                 (10,10,50,100)) # (x, y, w, h)

pygame.draw.polygon(screen,      # Where to draw the polygon
                    (0,255,0),   # the color (r,g,b)
                    ((10,200),   # pt (x,y)
                     (50,200),   # pt (x,y)
                     (30,250)))  # pt (x,y)

pygame.draw.circle(screen,       # Where to draw the circle
                   (0,0,255),    # color (r,g,b)
                   (200,60),     # (x, y)
                   50)           # radius

pygame.draw.ellipse(screen,      # where to draw the ellipse
                    (255,255,0), # color (r,g,b)
              (150,200, 100,50)) #(x, y, w, h)

pygame.draw.arc(screen,          # where to draw the ellipse
                (0,255,255),     # color (r,g,b)
                (300,10,100,100),# (x, y, w, h)
                0,               # start angle
                1.5 * math.pi)   # end angle

pygame.draw.line(screen,         # where to draw the line
                 (255,0,255),    # color (r,g,b)
                 (20,350),       # start (x,y)
                 (380,350),      # end (x,y)
                 4)              # width

#http://www.pygame.org/docs/ref/display.html#pygame.display.flip
#update the game window
pygame.display.flip()

#Loop for ever
while True:

    #process mouse and keyboard events
    for event in pygame.event.get():
        #the QUIT event is when you click on the "X" on the window.
        if event.type == QUIT:
            #exit the program
            pygame.quit()
            exit(0)
        
